package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.api.domain.*;
import com.spzx.product.api.factory.SpzxServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author ChenXing
 * @Description  两个接口一起写,同时测试降级服务
 * @Create 2024/8/7 19:27
 */

@FeignClient(contextId = "remoteSpzxService", value = ServiceNameConstants.PRODUCT_SERVICE,fallbackFactory = SpzxServiceFallback.class)
public interface SpzxService {

    @GetMapping(value = "/category/getOneCategory")
    R<List<CategoryVo>> getOneCategory(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/product/getTopSale")
    R<List<ProductSku>> getTopSale(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/product/skuList/{pageNum}/{pageSize}")
    R<TableDataInfo> skuList(@PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize,
                             @SpringQueryMap SkuQuery skuQuery, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/brand/getBrandAll")
    R<List<Brand>> getBrandAll(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/product/getProductSku/{skuId}")
    R<ProductSku>  getProductSku(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/product/getProduct/{skuId}")
    R<Product> getProduct(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/product/getSkuPrice/{skuId}")
    R<SkuPrice> getSkuPrice(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/product/getProductDetails/{skuId}")
    R<ProductDetails> getProductDetails(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/product/getSkuStockVo/{skuId}")
    R<SkuStockVo> getSkuStockVo(@PathVariable("skuId") Long skuId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/product/getProductSkuList/{id}")
    R<List<ProductSku>> getProductSkuList(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/product/getSkuPriceList")
    R<List<SkuPrice>> getSkuPriceList(@RequestBody List<Long> skuIds, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @PostMapping("/product/checkAndLock/{tradeNo}")
    R<String> checkAndLock(@PathVariable("tradeNo") String tradeNo, @RequestBody List<SkuLockVo> skuLockVoList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
